# 本项目生成一个动态的库
cmake_minimum_required(VERSION 3.16)

project(inner_common)

include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}
)

add_subdirectory(debug_log)
add_subdirectory(utils)

link_directories(
    ${debug_log_BINARY_DIR}
    ${utils_BINARY_DIR}
    ${INNER_LIB_DIR}
)

add_library(${PROJECT_NAME} SHARED      # SHARED 动态库；STATIC 静态库
    $<TARGET_OBJECTS:debug_log>
    $<TARGET_OBJECTS:utils>
)

target_link_libraries(${PROJECT_NAME}
    debug_log
    utils
)

add_dependencies(${PROJECT_NAME} debug_log)
add_dependencies(${PROJECT_NAME} utils)

set_target_properties(${PROJECT_NAME} PROPERTIES LINK_OPTIONS -s) # strip

# install(TARGETS ${PROJECT_NAME}
#     RUNTIME DESTINATION bin
#     LIBRARY DESTINATION lib
#     ARCHIVE DESTINATION lib
# )
install(TARGETS ${PROJECT_NAME}
    RUNTIME DESTINATION ${INNER_BIN_DIR}
    LIBRARY DESTINATION ${INNER_LIB_DIR}
    ARCHIVE DESTINATION ${INNER_LIB_DIR}
)